<?php
include_once(_CORE_PATH. "entity_prototype.php");
class MediaEntity extends entity_prototype
{ 
	protected $_name = 'media';
	
	public function __construct()
	{
		
	}
	
	public function SetId($id)
	{
		$this->Set('id', (int)$id);		
	}

	public function GetDateCreated($format = 'd.m.Y H:i')
	{
		return date($format, $this->Get('dateCreated'));		
	}	
	
	public function SetDateCreated($date)
	{
		$mktime = strtotime($date);
		$this->Set('dateCreated', $mktime === false ? time(): $mktime);
	}

	public function GetPublishDate($format = 'd.m.Y H:i')
	{
		return date($format, $this->Get('publishDate'));		
	}	
	
	public function SetPublishDate($date)
	{
		$mktime = strtotime($date);
		$this->Set('publishDate', $mktime === false ? time(): $mktime);
	}	
	
	public function SetTempFile($tempFile)
	{
		$this->Set('tempFile', $tempFile);
	}
	
	public function GetThumbnail()
	{
		return $this->Get('thumbnail');
	}
	
	public function GetStatusName()
	{
		return MatchMediaStatus::Get($this->Get('status'));
	}

	public function SetCode($code = null)
	{
		$this->Set('code', $code);	
	}	
	
	public function GetCodeSql()
	{
		$val = $this->Get('code');
		if (is_null($val)) return 'NULL';
		return $val;			
	}	
}